<?php
class DefaultController extends BaseController
{

	public function actionIndex(){
		// $this->uid = obj('User')->is_login();//TODO:后期转为js 减少服务端的压力
		//echo 'index test',BASE_DIR;
		$this->items = obj('Define')->get_items();
		$item = $this->_key(1);
		$time = time();
		if(in_array($item,$this->items)) { //后面有参数, 可能要指向相应的item首页
			
			$this->item = $item;
			$this->funcs = obj('Func')->select("item_name='$item' and flag=1 and cr_time<$time",'func_name','id DESC', 1000);
			$this->display('default_index_item.tpl');
		}else {
			//TODO:随机有待改进
			$this->func = obj('Func')->find("flag=1 and cr_time<$time",'','cr_time desc');
			$this->funcs = obj('Func')->select("flag=1 and cr_time<$time",'item_name,func_name','cr_time DESC', 20);
			$this->sections = obj('Book')->select("flag=1 and cr_time<$time",'book_id,section_id,title_en','cr_time DESC', 5);
			// var_dump($this->funcs);
			$this->display('default_index.tpl');
		}
	}
	
	public function actionTest(){
		echo 'index test',BASE_PATH;
	}
	
}